<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>

<!-- ========================= -->
<!-- root element: InventorypackingSlip -->
<!-- ========================= -->
<xsl:template match="InventorypackingSlip">

	<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <!-- ========================= -->
    <!-- gobal variables           -->
    <!-- ========================= -->
    <xsl:variable name="cancelImagePath" select="images//cancelImage"/>
    <xsl:variable name="logoPath" select="images//logo"/>

  	<fo:layout-master-set>
		<fo:simple-page-master master-name="A4-portrait"
        		page-height="11in"
        		page-width="8.5in"
        		margin-top="20mm"
        		margin-bottom="12mm"
      			margin-left="10mm"
      			margin-right="10mm">

            <fo:region-after extent="5mm"/>

			<!-- ========================================================  -->
			<!-- Inorder to check whether packing slip is cancelled or not -->
			<!-- ========================================================  -->

			<xsl:if test="@cancel='0'">
			<fo:region-body />
			</xsl:if>

			<xsl:if test="@cancel='1'">
			<fo:region-body background-image="{$cancelImagePath}" />
			</xsl:if>

  		</fo:simple-page-master>
	</fo:layout-master-set>


<fo:page-sequence master-reference="A4-portrait">
<!--============================== -->
<!-- Page Number block             -->
<!--============================== -->

<fo:static-content flow-name="xsl-region-after">
	<fo:block font-size="7pt" font-weight="bold" text-align="right">
        Page <fo:page-number />
	<!--
	<xsl:value-of select="count(/packingSlip/lineItems/lineItem)"/>
	-->
	 of
	<fo:page-number-citation ref-id="endofdoc"/>
	<!--
	<fo:page-number-citation ref-id="last-page"/>
	-->
   </fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
    <!--==============================-->
    <!-- Logo and Self address block  -->
    <!--==============================-->
	<fo:block font-size="8pt" space-after="1cm">
	<fo:table table-layout="fixed" width="100%" >
    <fo:table-column column-width="35mm"/>
	<fo:table-column column-width="20mm" />
	<fo:table-column display-align="center" />
	<fo:table-column />
	<fo:table-body>
		<fo:table-row>
			<fo:table-cell>
            <fo:external-graphic src="{$logoPath}" content-height = ".5in"  content-width = ".5in" />
	     	</fo:table-cell>
			<fo:table-cell />
            <fo:table-cell text-align="center">
                <fo:block font-size="12pt" font-weight="bold" display-align="center">Inventory Packing Slip</fo:block>
            </fo:table-cell>
            <fo:table-cell display-align="center">
                <fo:table table-layout="fixed" width="100%" >
                    <fo:table-column />
                    <fo:table-column display-align="center" />
                    <fo:table-body>
                        <fo:table-row>
                            <fo:table-cell> </fo:table-cell>
                            <fo:table-cell hyphenate="true" display-align="center">
                                <fo:block font-size="7pt" font-weight="bold" text-align="center"><xsl:value-of select="selfAddress//name" /></fo:block>
                                <fo:block font-size="7pt" font-weight="bold" text-align="center"><xsl:value-of select="selfAddress//address1" /></fo:block>
                                <fo:block font-size="7pt" font-weight="bold" text-align="center"><xsl:value-of select="selfAddress//address2" /></fo:block>
                                <fo:block font-size="7pt" font-weight="bold" text-align="center"><xsl:value-of select="selfAddress//address3" /></fo:block>
                                <fo:block font-size="7pt" font-weight="bold" text-align="center"><xsl:value-of select="selfAddress//address4" /></fo:block>
                                <fo:block font-size="7pt" font-weight="bold" text-align="center"><xsl:value-of select="selfAddress//state" /></fo:block>
                                <fo:block font-size="7pt" font-weight="bold" text-align="center"><xsl:value-of select="selfAddress//phone" /></fo:block>
                                <fo:block font-size="7pt" font-weight="bold" text-align="center"><xsl:value-of select="selfAddress//fax" /></fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
            </fo:table-cell>
        </fo:table-row>
	</fo:table-body>
	</fo:table >
	</fo:block>
    <!--==============================-->
    <!-- From and To addresses block  -->
    <!--==============================-->
	<fo:table table-layout="fixed" width="100%" space-after="1cm">
		<fo:table-column column-width="60mm"/>
		<fo:table-column column-width="60mm"/>
		<fo:table-column column-width="60mm"/>
		<fo:table-body>
			<fo:table-row>
				<fo:table-cell hyphenate="true">
			 		<fo:block font-size="8pt" > <xsl:apply-templates select="shipFromAddress"/> </fo:block>
				</fo:table-cell>
				<fo:table-cell/>
				<fo:table-cell hyphenate="true">
			 		<fo:block font-size="8pt" > <xsl:apply-templates select="shipToAddress"/> </fo:block>
				</fo:table-cell>
			</fo:table-row>
		</fo:table-body>
	</fo:table>
    <!--=============================== -->
    <!-- Shipping Instructions block    -->
    <!--=============================== -->
    <fo:block font-size="8pt" font-weight="bold" space-after="2mm" text-decoration="underline">Shipping Instructions:</fo:block>
    <fo:block font-size="8pt" background-color="#DEE1E2" space-after="1cm" > <xsl:value-of select="ShippingInstructions"/> </fo:block>
    <!--===============================-->
    <!-- Information block             -->
    <!--===============================-->
	<fo:block font-size="8pt">
		<xsl:apply-templates select="information"/>
	</fo:block>

    <!--=============================== -->
    <!-- Line Items details block      -->
    <!--=============================== -->
	<fo:block font-size="8pt" space-after="1cm">
        <xsl:apply-templates select="lotDetails"/>
    </fo:block>
    <!--=============================== -->
    <!-- Footer block                   -->
    <!--=============================== -->
	<fo:table margin="1cm" width="100%" table-layout="fixed">
       <fo:table-column column-width="140mm" />
	       <fo:table-body>
	       <fo:table-row>
	       <fo:table-cell display-align="center">
		       <fo:block text-align="center" font-size="10pt" font-weight="bold" space-after="2mm">
			    CERTIFICATE OF COMPLIANCE
       	       </fo:block>
	       </fo:table-cell>
	       </fo:table-row>
	       <fo:table-row>
	       <fo:table-cell display-align="center">
		       <fo:block text-align="left" font-size="7pt" font-weight="bold" space-after="1mm">
				THIS PRODUCT SHIPPED HERE WITH HAVE BEEN INSPECTED AND COMPLY WITH THE REQUIREMENTS
				OF YOUR PURCHASE ORDER TO THE EXTENT THAT SUCH REQUIREMENTS HAVE BEEN ACCEPTED AND
				ACKNOWLEDGED BY	<xsl:value-of select="selfAddress//cName" /> SUBSTANTIATING INSPECTION AND TEST ON FILE.
         	   </fo:block>
               <fo:block text-align="left" font-size="7pt" font-weight="bold" space-after="0">
				WE CERTIFY THAT INSPECTION EVIDENCE, INCLUDING TEST DATA,NECESSARY TO SUBSTANTIATE THIS CERTIFICATION
                IS AVAILABLE FROM OUR FILES.
               </fo:block>
           </fo:table-cell>
	       </fo:table-row>
	       <fo:table-row>
	       <fo:table-cell display-align="center">
		       <fo:block text-align="center" font-size="7pt" font-weight="bold" space-after="1cm">
				THANK YOU FOR YOUR BUSINESS!
       	       </fo:block>
	       </fo:table-cell>
	       </fo:table-row>
	       </fo:table-body>
	</fo:table>
	<fo:table margin="1cm" width="100%" table-layout="fixed">
	       <fo:table-column column-width="50mm" />
           <fo:table-column column-width="45mm" />
           <fo:table-column column-width="45mm" />
	       <fo:table-body>
	       <fo:table-row>
	       <fo:table-cell display-align="center">
		       <fo:block text-align="left" font-size="7pt" font-weight="bold" space-after="1cm">
				Packed By:
       	       </fo:block>
		       <fo:block text-align="left" font-size="7pt" font-weight="bold" space-after="1cm">
               Checked By:
               </fo:block>
               <fo:block space-after="1cm"></fo:block>
	       </fo:table-cell>
	       <fo:table-cell display-align="center">
		       <!--<fo:block>
		       <fo:leader leader-pattern="rule" leader-length="2.5in" rule-thickness="1pt" color="black" /></fo:block>-->
		       <fo:block border-bottom="1pt dashed black" font-size="6pt">
                   <xsl:value-of select="/InventorypackingSlip/information/signature"/>
               </fo:block>
		       <fo:block text-align="left" font-size="6pt" font-weight="bold" space-after="1cm">
			    Name/Signature
         	   </fo:block>
		       <fo:block border-bottom="1pt dashed black" font-size="6pt">
                   <xsl:value-of select="/InventorypackingSlip/information/signature"/>
               </fo:block>
		       <fo:block text-align="left" font-size="6pt" font-weight="bold" space-after="1cm">
		       Name/Signature
	           </fo:block>
               <fo:block space-after="1cm"></fo:block>
           </fo:table-cell>
	       </fo:table-row>
               </fo:table-body>
           </fo:table>
            <!-- Inorder to get page count -->
          <fo:block id="endofdoc"></fo:block>
    </fo:flow>
    </fo:page-sequence>
    </fo:root>
</xsl:template>

<!-- ================================ -->
<!--  Child element: Ship From Address  -->
<!-- ================================ -->
<xsl:template match="shipFromAddress">
	<fo:table margin="2mm" width="100%" table-layout="fixed">
		<fo:table-column />
	        <fo:table-body>
			<fo:table-row height="0.5cm">
				<fo:table-cell background-color="#DEE1E2" border="1pt double black" display-align="center">
				<fo:block font-weight="bold">Ship From:</fo:block>
				</fo:table-cell>
			</fo:table-row>

			<fo:table-row height="4cm">
				<fo:table-cell font-weight="bold" background-color="#FFFFEE" border="1pt double black" display-align="top">
				<fo:block space-before="2mm" ><xsl:value-of select="name"/></fo:block>
                <fo:block><xsl:value-of select="contactPerson"/></fo:block>
                <fo:block><xsl:value-of select="address1"/></fo:block>
				<fo:block><xsl:value-of select="address2"/></fo:block>
				<fo:block><xsl:value-of select="address3"/></fo:block>
				<fo:block><xsl:value-of select="address4"/></fo:block>
				<fo:block><xsl:value-of select="city"/></fo:block>
			    <fo:block><xsl:value-of select="state"/></fo:block>
				<fo:block><xsl:value-of select="phone"/></fo:block>
				<fo:block><xsl:value-of select="fax"/></fo:block>
                <fo:block><xsl:value-of select="cellno"/></fo:block>
		        <fo:block><xsl:value-of select="email"/></fo:block>
				</fo:table-cell>
			</fo:table-row>
		</fo:table-body>
	</fo:table>
</xsl:template>

<!-- =================================== -->
<!--	Child element: Ship To Address   -->
<!-- =================================== -->
<xsl:template match="shipToAddress">
	<fo:table margin="2mm" width="100%" table-layout="fixed">
		<fo:table-column />
		<fo:table-body>
			<fo:table-row height="0.5cm">
				<fo:table-cell background-color="#DEE1E2" border="1pt double black" display-align="center">
				<fo:block font-weight="bold">Ship To:</fo:block>
				</fo:table-cell>
			</fo:table-row>
			<fo:table-row height="4cm">
				<fo:table-cell font-weight="bold" background-color="#FFFFEE" border="1pt double black" display-align="top">
				<fo:block space-before="2mm"><xsl:value-of select="name"/></fo:block>
				<fo:block><xsl:value-of select="contactPerson"/></fo:block>
                <fo:block><xsl:value-of select="address1"/></fo:block>    
				<fo:block><xsl:value-of select="address2"/></fo:block>
				<fo:block><xsl:value-of select="address3"/></fo:block>
				<fo:block><xsl:value-of select="address4"/></fo:block>
                <fo:block><xsl:value-of select="city"/></fo:block>
                <fo:block><xsl:value-of select="state"/></fo:block>
				<fo:block><xsl:value-of select="phone"/></fo:block>
				<fo:block><xsl:value-of select="fax"/></fo:block>
                <fo:block><xsl:value-of select="cellno"/></fo:block>
                <fo:block><xsl:value-of select="email"/></fo:block>
				</fo:table-cell>
			</fo:table-row>
		</fo:table-body>
	</fo:table>
</xsl:template>

<!-- =================================== -->
<!--	child element: Information       -->
<!-- =================================== -->
<xsl:template match="information">
	<fo:block font-size="7pt">
        <fo:table space-after="1cm" width="100%" table-layout="fixed">
		<fo:table-column column-width="50mm" />
        <fo:table-column column-width="45mm" />
        <fo:table-column column-width="35mm" />
        <fo:table-column column-width="33mm" />
		<fo:table-column column-width="31mm"/>
		
        <fo:table-body>
			<fo:table-row height="0.5cm" background-color="#DEE1E2">
				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">PackingSlip#</fo:block>
				</fo:table-cell>
  				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">Ship Date</fo:block>
				 </fo:table-cell>
				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">Way Bill</fo:block>
				</fo:table-cell>
				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">#Cartons</fo:block>
				</fo:table-cell>
                <fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">Weight(Lbs)</fo:block>
				</fo:table-cell>
                
            </fo:table-row>
			<fo:table-row  height="0.4cm" background-color="#FFFFEE">

				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">
					<xsl:value-of select="packingSlipNo"/>
					</fo:block>
				</fo:table-cell>
				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">
					<xsl:value-of select="actualShipDate"/>
					</fo:block>
				</fo:table-cell>
				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">
					<xsl:value-of select="wayBill"/>
					</fo:block>
				</fo:table-cell>
				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">
					<xsl:value-of select="cartons"/>
					</fo:block>
				</fo:table-cell>
				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="right">
					<xsl:value-of select="grossWeight"/>
					</fo:block>
				</fo:table-cell>
            </fo:table-row>
            </fo:table-body>
        </fo:table>
        </fo:block>
</xsl:template>

<!-- =================================== -->
<!--	child element: lotDetails	   -->
<!-- =================================== -->
<xsl:template match="lotDetails">
	<fo:block font-size="7pt">
        <fo:table space-after="1cm" width="100%" table-layout="fixed">

            <fo:table-column column-width="40mm"/>
            <fo:table-column column-width="30mm"/>
            <fo:table-column column-width="20mm"/>
            <fo:table-column column-width="20mm"/>
            <fo:table-column column-width="10mm"/>
            <fo:table-column column-width="15mm"/>
            <fo:table-column column-width="60mm"/>

            <fo:table-body>
			<fo:table-row height="0.6cm" background-color="#DEE1E2">
				
	  			<fo:table-cell border="1pt double black" display-align="center" >
		    			<fo:block font-weight="bold" text-align="center">Part Number</fo:block>
	  			</fo:table-cell>
	  			<fo:table-cell border="1pt double black" display-align="center" >
		    			<fo:block font-weight="bold" text-align="center">Description</fo:block>
	  			</fo:table-cell>
	  			<fo:table-cell border="1pt double black" display-align="center" >
		    			<fo:block font-weight="bold" text-align="center">Lot Number</fo:block>
	  			</fo:table-cell>
	  			<fo:table-cell border="1pt double black" display-align="center" >
		    			<fo:block font-weight="bold" text-align="center">Fab Lot Number</fo:block>
	  			</fo:table-cell>
	  			<fo:table-cell border="1pt double black" display-align="center" >
					<fo:block font-weight="bold" text-align="center">Wafer Qty</fo:block>
				</fo:table-cell>
                <fo:table-cell border="1pt double black" display-align="center" >
					<fo:block font-weight="bold" text-align="center">Die Qty</fo:block>
				</fo:table-cell>
				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">WaferIds</fo:block>
				</fo:table-cell>

			</fo:table-row>
			<xsl:for-each select="/InventorypackingSlip/lotDetails/lotInfo">
			<fo:table-row height="0.4cm" background-color="#FFFFEE">

				<fo:table-cell border="1pt double black" display-align="center" hyphenate="true" language = "en">
					<fo:block font-weight="bold" text-align="center">
					<xsl:value-of select="mfgPartNumber"/>
					</fo:block>
				</fo:table-cell>
				<fo:table-cell border="1pt double black" display-align="center" hyphenate="true" language = "en">
					<fo:block font-weight="bold" text-align="center">
					<xsl:value-of select="description"/>
					</fo:block>
				</fo:table-cell>
				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">
					<xsl:value-of select="lotNumber"/>
					</fo:block>
				</fo:table-cell>
				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">
					<xsl:value-of select="fabLotNumber"/>
					</fo:block>
				</fo:table-cell>
				<fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">
					<xsl:value-of select="shipQty"/>
					</fo:block>
				</fo:table-cell>
                <fo:table-cell border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">
					<xsl:value-of select="shipDieQty"/>
					</fo:block>
				</fo:table-cell>
				<fo:table-cell hyphenate="true" language="en" border="1pt double black" display-align="center">
					<fo:block font-weight="bold" text-align="center">
					<xsl:value-of select="waferIds"/>
					</fo:block>
				</fo:table-cell>
			</fo:table-row>
			</xsl:for-each>
		</fo:table-body>
	</fo:table>
	</fo:block>
</xsl:template>
<!-- =================================== -->
<!--	END of Document		         -->
<!-- =================================== -->
</xsl:stylesheet>
